package com.iknow;

import android.graphics.Bitmap;
import com.iknow.app.IKnowSystemConfig;
import com.iknow.data.Comment;
import com.iknow.data.QingBo;
import com.iknow.data.QingboType;
import com.iknow.data.SubscribeTag;
import com.iknow.data.Word;
import com.iknow.db.IKnowDataBase;
import com.iknow.file.CacheSystem;
import com.iknow.http.HttpClient;
import com.iknow.http.HttpException;
import com.iknow.http.Response;
import com.iknow.image.ImageManager;
import com.iknow.image.ProfileImageCacheManager;
import com.iknow.util.Loger;
import com.iknow.util.StringUtil;
import com.iknow.util.SystemUtil;
import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class IKnowApiV4
{
  public static final String BASE_CONTENT_URL = "http://www.imiknow.com/iks/c";
  public static final String BASE_FILE_SERVER = "http://www.imiknow.com/iks";
  public static final String BASE_USER_URL = "http://www.imiknow.com/iks/u";
  public static final String CONSUMER_KEY = "2832649083";
  public static final String CONSUMER_SECRET = "191a6c08a5d3f783a5bd0de5accd180b";
  public static final String DEFAULT_PASSWROD = "111111";
  public static final String OFFICIAL = "im_qplus";
  public static final boolean OPERATEABLE = 0;
  public static final String QPLUS = "im_qplus";
  public static final String SERVER_DOMAIN = "www.imiknow.com";
  public static final String SQUARE_ID = "b65cfaefe89c7fe21afa7374a32ed831";
  public static final String XMPPSERVER_NAME = "imiknow.com";
  public static final String XMPPSERVER_PATH = "imiknow.com";
  public static final int XMPPSERVER_PORT = 5222;
  private static final String domain = "http://www.imiknow.com/iks";
  private final String TAG = "IKnowApiV4";
  protected HttpClient http = null;
  private String mSessionID = null;

  public IKnowApiV4()
  {
    this.http = new HttpClient();
  }

  public static String formatFileUrl(String paramString)
  {
    String str;
    if (paramString.indexOf("http://") != -1)
      str = paramString;
    while (true)
    {
      return str;
      int i = paramString.indexOf("..");
      if (-1 != i)
        paramString = paramString.substring(i + 2);
      str = "http://www.imiknow.com/iks" + paramString;
    }
  }

  public static String getResizeAvatarImageUrl(String paramString)
  {
    Object[] arrayOfObject = new Object[3];
    arrayOfObject[0] = "http://www.imiknow.com/iks/c";
    arrayOfObject[1] = paramString;
    arrayOfObject[2] = Integer.valueOf(70);
    return String.format("%s/resize_img.do?path=%s&width=%d", arrayOfObject);
  }

  public static String getResizeContentImageUrl(String paramString)
  {
    String str;
    if (StringUtil.isEmpty(paramString))
      str = null;
    while (true)
    {
      return str;
      int i = SystemUtil.getDisplayWidth();
      Object[] arrayOfObject = new Object[3];
      arrayOfObject[0] = "http://www.imiknow.com/iks/c";
      arrayOfObject[1] = paramString;
      arrayOfObject[2] = Integer.valueOf(i);
      str = String.format("%s/resize_img.do?path=%s&width=%d", arrayOfObject);
    }
  }

  public static String getResizeThumbnailImageUrl(String paramString)
  {
    String str;
    if (StringUtil.isEmpty(paramString))
      str = null;
    while (true)
    {
      return str;
      int i = 2 * SystemUtil.getDisplayWidth() / 3;
      Object[] arrayOfObject = new Object[3];
      arrayOfObject[0] = "http://www.imiknow.com/iks/c";
      arrayOfObject[1] = paramString;
      arrayOfObject[2] = Integer.valueOf(i);
      str = String.format("%s/resize_img.do?path=%s&width=%d", arrayOfObject);
    }
  }

  private List<QingBo> parseListByLocalResponse(String paramString)
    throws HttpException
  {
    ArrayList localArrayList = new ArrayList();
    String str = IKnow.mCacheSystem.readFile(paramString);
    if (StringUtil.isEmpty(str))
      return localArrayList;
    Response localResponse = new Response();
    localResponse.setResponseAsString(str);
    Iterator localIterator = QingboResponse.QingboResponses(localResponse).iterator();
    while (true)
    {
      if (!(localIterator.hasNext()));
      localArrayList.add(new QingBo((QingboResponse)localIterator.next()));
    }
  }

  public String chageAvatar(String paramString)
    throws HttpException
  {
    ArrayList localArrayList = new ArrayList();
    localArrayList.add(new BasicNameValuePair("file", "file"));
    try
    {
      String str = formatFileUrl(this.http.httpRequest("http://www.imiknow.com/iks/u/upload.do", localArrayList, new File(paramString), true, "POST").asJSONObject().getString("path"));
      return str;
    }
    catch (HttpException localHttpException)
    {
      throw localHttpException;
    }
    catch (JSONException localJSONException)
    {
      throw new HttpException(localJSONException.getMessage());
    }
  }

  // ERROR //
  public Map<String, Object> checkUpdate()
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_1
    //   2: aload_0
    //   3: getfield 58	com/iknow/IKnowApiV4:http	Lcom/iknow/http/HttpClient;
    //   6: ldc 219
    //   8: aconst_null
    //   9: iconst_0
    //   10: ldc 192
    //   12: invokevirtual 222	com/iknow/http/HttpClient:httpRequest	(Ljava/lang/String;Ljava/util/ArrayList;ZLjava/lang/String;)Lcom/iknow/http/Response;
    //   15: invokevirtual 200	com/iknow/http/Response:asJSONObject	()Lorg/json/JSONObject;
    //   18: astore 5
    //   20: aload 5
    //   22: ldc 224
    //   24: invokevirtual 207	org/json/JSONObject:getString	(Ljava/lang/String;)Ljava/lang/String;
    //   27: astore 6
    //   29: aload 6
    //   31: ldc 226
    //   33: invokestatic 230	com/iknow/util/StringUtil:equalsString	(Ljava/lang/Object;Ljava/lang/Object;)Z
    //   36: ifeq +9 -> 45
    //   39: aconst_null
    //   40: astore 4
    //   42: goto +190 -> 232
    //   45: new 232	java/util/HashMap
    //   48: dup
    //   49: invokespecial 233	java/util/HashMap:<init>	()V
    //   52: astore 7
    //   54: aload 6
    //   56: ldc 235
    //   58: invokestatic 230	com/iknow/util/StringUtil:equalsString	(Ljava/lang/Object;Ljava/lang/Object;)Z
    //   61: ifeq +133 -> 194
    //   64: aload 7
    //   66: ldc 237
    //   68: iconst_1
    //   69: invokestatic 242	java/lang/Boolean:valueOf	(Z)Ljava/lang/Boolean;
    //   72: invokeinterface 248 3 0
    //   77: pop
    //   78: new 81	java/lang/StringBuilder
    //   81: dup
    //   82: ldc 11
    //   84: invokespecial 84	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   87: aload 5
    //   89: ldc 250
    //   91: invokevirtual 207	org/json/JSONObject:getString	(Ljava/lang/String;)Ljava/lang/String;
    //   94: invokevirtual 88	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   97: invokevirtual 92	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   100: astore 10
    //   102: aload 7
    //   104: ldc 252
    //   106: aload 5
    //   108: ldc 254
    //   110: invokevirtual 207	org/json/JSONObject:getString	(Ljava/lang/String;)Ljava/lang/String;
    //   113: invokeinterface 248 3 0
    //   118: pop
    //   119: aload 7
    //   121: ldc_w 256
    //   124: aload 5
    //   126: ldc_w 258
    //   129: invokevirtual 207	org/json/JSONObject:getString	(Ljava/lang/String;)Ljava/lang/String;
    //   132: invokeinterface 248 3 0
    //   137: pop
    //   138: aload 7
    //   140: ldc_w 260
    //   143: aload 5
    //   145: ldc_w 262
    //   148: invokevirtual 207	org/json/JSONObject:getString	(Ljava/lang/String;)Ljava/lang/String;
    //   151: invokeinterface 248 3 0
    //   156: pop
    //   157: aload 7
    //   159: ldc_w 264
    //   162: aload 5
    //   164: ldc 224
    //   166: invokevirtual 207	org/json/JSONObject:getString	(Ljava/lang/String;)Ljava/lang/String;
    //   169: invokeinterface 248 3 0
    //   174: pop
    //   175: aload 7
    //   177: ldc_w 266
    //   180: aload 10
    //   182: invokeinterface 248 3 0
    //   187: pop
    //   188: aload 7
    //   190: astore_1
    //   191: goto +44 -> 235
    //   194: aload 7
    //   196: ldc 237
    //   198: iconst_0
    //   199: invokestatic 242	java/lang/Boolean:valueOf	(Z)Ljava/lang/Boolean;
    //   202: invokeinterface 248 3 0
    //   207: pop
    //   208: goto -130 -> 78
    //   211: astore 8
    //   213: aload 8
    //   215: astore_3
    //   216: aload 7
    //   218: astore_1
    //   219: aload_3
    //   220: invokevirtual 269	java/lang/Exception:printStackTrace	()V
    //   223: goto +12 -> 235
    //   226: astore_2
    //   227: aload_2
    //   228: astore_3
    //   229: goto -10 -> 219
    //   232: aload 4
    //   234: areturn
    //   235: aload_1
    //   236: astore 4
    //   238: goto -6 -> 232
    //
    // Exception table:
    //   from	to	target	type
    //   54	208	211	java/lang/Exception
    //   2	54	226	java/lang/Exception
  }

  public void comment(String paramString1, String paramString2)
    throws HttpException
  {
    Object[] arrayOfObject = new Object[2];
    arrayOfObject[0] = paramString1;
    arrayOfObject[1] = paramString2;
    String str = String.format("{\"cid\":\"%s\",\"value\":\"%s\"}", arrayOfObject);
    try
    {
      post("http://www.imiknow.com/iks/c/add_comment.do?", "json", str, true);
      return;
    }
    catch (HttpException localHttpException)
    {
      throw localHttpException;
    }
  }

  public JSONObject createFavoriteJsonString(QingBo paramQingBo)
  {
    HashMap localHashMap = new HashMap();
    localHashMap.put("content", paramQingBo.getID());
    localHashMap.put("keyword", paramQingBo.getTags());
    localHashMap.put("description", "");
    return new JSONObject(localHashMap);
  }

  public JSONArray createFavoriteQingBoJSONArrayString(List<QingBo> paramList)
  {
    JSONArray localJSONArray = new JSONArray();
    Iterator localIterator = paramList.iterator();
    while (true)
    {
      if (!(localIterator.hasNext()))
        return localJSONArray;
      localJSONArray.put(createFavoriteJsonString((QingBo)localIterator.next()));
    }
  }

  public JSONArray createFavoriteWrodJSONArrayString(List<Word> paramList)
    throws HttpException
  {
    String str1;
    String str2;
    JSONArray localJSONArray = new JSONArray();
    Iterator localIterator = paramList.iterator();
    if (!(localIterator.hasNext()))
      return localJSONArray;
    Word localWord = (Word)localIterator.next();
    JSONObject localJSONObject = new JSONObject();
    try
    {
      str1 = localWord.getMemo();
      str2 = StringUtil.DateToStr(localWord.getCreateDate());
      localJSONObject.put("audio_url", localWord.getAudioUrl());
      localJSONObject.put("lang", localWord.getLang());
      localJSONObject.put("def", localWord.getDef());
      localJSONObject.put("keyword", new String());
      localJSONObject.put("pron", localWord.getPron());
      localJSONObject.put("familiarity", new String());
      if (StringUtil.isEmpty(str1))
      {
        localJSONObject.put("description", IKnow.mIKnowDataBase.getWordMemo(localWord.getKey()));
        localJSONObject.put("word", localWord.getKey());
        if (!(StringUtil.isEmpty(str2)))
          break label257;
        localJSONObject.put("record_time", StringUtil.DateToStr(new Date()));
        label257: localJSONArray.put(localJSONObject);
      }
    }
    catch (JSONException localJSONException)
    {
      while (true)
      {
        while (true)
        {
          throw new HttpException(localJSONException.getMessage());
          localJSONObject.put("description", str1);
        }
        localJSONObject.put("record_time", str2);
      }
    }
  }

  public JSONObject createJSONObject(HashMap<String, String> paramHashMap)
  {
    return new JSONObject(paramHashMap);
  }

  public ArrayList<BasicNameValuePair> createParams(BasicNameValuePair[] paramArrayOfBasicNameValuePair)
  {
    ArrayList localArrayList = new ArrayList();
    int i = paramArrayOfBasicNameValuePair.length;
    int j = 0;
    while (true)
    {
      if (j >= i)
        return localArrayList;
      localArrayList.add(paramArrayOfBasicNameValuePair[j]);
      ++j;
    }
  }

  public String createQingBoJSONString(QingBo paramQingBo)
  {
    JSONObject localJSONObject;
    HashMap localHashMap = new HashMap();
    localHashMap.put("id", paramQingBo.getID());
    localHashMap.put("name", paramQingBo.getTitle());
    localHashMap.put("des", paramQingBo.getSubject());
    localHashMap.put("open_count", paramQingBo.getHot());
    localHashMap.put("favorite_count", paramQingBo.getFavoriteCount());
    localHashMap.put("comment_count", paramQingBo.getCommentCount());
    if (paramQingBo.getType() == QingboType.text)
    {
      localHashMap.put("type", "text/html;charset=utf-8");
      if (paramQingBo.getThumbnailUrl() != null)
        localHashMap.put("image_url", paramQingBo.getThumbnailUrl());
      localHashMap.put("create_time", StringUtil.DateToStr(paramQingBo.getCreateTime()));
      localHashMap.put("user_id", paramQingBo.getAuthorID());
      localHashMap.put("user_name", paramQingBo.getAuthorName());
      localJSONObject = new JSONObject(localHashMap);
    }
    try
    {
      do
        while (true)
        {
          localJSONObject.put("tags", createTags(paramQingBo.getTags()));
          return localJSONObject.toString();
          if (paramQingBo.getType() != QingboType.image)
            break;
          localHashMap.put("type", "text/html;image/jpeg;charset=utf-8");
        }
      while (paramQingBo.getType() != QingboType.audio);
      localHashMap.put("type", "audio/mpeg");
    }
    catch (JSONException localJSONException)
    {
      while (true)
        localJSONException.printStackTrace();
    }
  }

  public String createQingBoJSONString(QingBo paramQingBo, String paramString1, String paramString2)
  {
    JSONObject localJSONObject;
    HashMap localHashMap = new HashMap();
    localHashMap.put("title", paramQingBo.getTitle());
    localHashMap.put("summary", paramQingBo.getSubject());
    if (paramQingBo.getType() == QingboType.text)
    {
      localHashMap.put("contentType", "text/html;charset=utf-8");
      if (paramQingBo.getThumbnailUrl() != null)
        localHashMap.put("coverUrl", paramQingBo.getThumbnailUrl());
      localHashMap.put("content", StringUtil.toUtf8String(paramString1));
      localJSONObject = new JSONObject(localHashMap);
    }
    try
    {
      do
        while (true)
        {
          localJSONObject.put("tags", createTags(paramQingBo.getTags()));
          return localJSONObject.toString();
          if (paramQingBo.getType() != QingboType.image)
            break;
          localHashMap.put("contentType", "text/html;image/jpeg;charset=utf-8");
        }
      while (paramQingBo.getType() != QingboType.audio);
      localHashMap.put("contentType", "audio/mpeg");
    }
    catch (JSONException localJSONException)
    {
      while (true)
        localJSONException.printStackTrace();
    }
  }

  public String createQingbo()
  {
    return null;
  }

  public JSONArray createQingboIdJSONArray(List<QingBo> paramList)
  {
    JSONArray localJSONArray = new JSONArray();
    Iterator localIterator = paramList.iterator();
    if (!(localIterator.hasNext()))
      return localJSONArray;
    QingBo localQingBo = (QingBo)localIterator.next();
    JSONObject localJSONObject = new JSONObject();
    try
    {
      localJSONObject.put("content", localQingBo.getID());
      localJSONArray.put(localJSONObject);
    }
    catch (JSONException localJSONException)
    {
      localJSONException.printStackTrace();
    }
  }

  public JSONArray createTags(String paramString)
  {
    String[] arrayOfString = paramString.split(",");
    ArrayList localArrayList = new ArrayList();
    int i = arrayOfString.length;
    int j = 0;
    while (true)
    {
      if (j >= i)
        return new JSONArray(localArrayList);
      String str = arrayOfString[j];
      if (!(StringUtil.isEmpty(str)))
        localArrayList.add(str);
      ++j;
    }
  }

  public void deleteQingbo(String paramString)
    throws HttpException
  {
    HashMap localHashMap = new HashMap();
    localHashMap.put("action", "3");
    localHashMap.put("id", paramString);
    post("http://www.imiknow.com/iks/a/content_edit.do", "json", new JSONObject(localHashMap).toString(), false);
  }

  public void doFavorite(OnlineAction paramOnlineAction, List<QingBo> paramList)
    throws HttpException
  {
    JSONArray localJSONArray2;
    JSONObject localJSONObject2;
    String str = null;
    if (paramOnlineAction == OnlineAction.Add)
    {
      localJSONArray2 = createFavoriteQingBoJSONArrayString(paramList);
      localJSONObject2 = new JSONObject();
    }
    do
      try
      {
        localJSONObject2.put("favorite", localJSONArray2);
        localJSONObject2.put("action", "1");
        str = localJSONObject2.toString();
        if (post("http://www.imiknow.com/iks/u/edit_favorite.do?", "json", str, true).getStatusCode() != 200)
          Loger.e("IKnowApiV4", "doFavorite error:!!");
        return;
      }
      catch (JSONException localJSONException2)
      {
        throw new HttpException(localJSONException2.getMessage());
      }
    while (paramOnlineAction != OnlineAction.Delete);
    JSONArray localJSONArray1 = createQingboIdJSONArray(paramList);
    JSONObject localJSONObject1 = new JSONObject();
    try
    {
      localJSONObject1.put("favorite", localJSONArray1);
      localJSONObject1.put("action", "2");
      str = localJSONObject1.toString();
    }
    catch (JSONException localJSONException1)
    {
      throw new HttpException(localJSONException1.getMessage());
    }
  }

  // ERROR //
  public void doWordFavorite(OnlineAction paramOnlineAction, List<Word> paramList)
    throws HttpException
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_3
    //   2: aload_1
    //   3: getstatic 488	com/iknow/OnlineAction:Add	Lcom/iknow/OnlineAction;
    //   6: if_acmpne +93 -> 99
    //   9: new 204	org/json/JSONObject
    //   12: dup
    //   13: invokespecial 311	org/json/JSONObject:<init>	()V
    //   16: astore 18
    //   18: aload 18
    //   20: ldc_w 362
    //   23: aload_0
    //   24: aload_2
    //   25: invokevirtual 516	com/iknow/IKnowApiV4:createFavoriteWrodJSONArrayString	(Ljava/util/List;)Lorg/json/JSONArray;
    //   28: invokevirtual 330	org/json/JSONObject:put	(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
    //   31: pop
    //   32: aload 18
    //   34: ldc_w 476
    //   37: ldc_w 494
    //   40: invokevirtual 330	org/json/JSONObject:put	(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
    //   43: pop
    //   44: aload 18
    //   46: invokevirtual 439	org/json/JSONObject:toString	()Ljava/lang/String;
    //   49: astore_3
    //   50: aload_0
    //   51: ldc_w 518
    //   54: ldc_w 276
    //   57: aload_3
    //   58: iconst_1
    //   59: invokevirtual 280	com/iknow/IKnowApiV4:post	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)Lcom/iknow/http/Response;
    //   62: invokevirtual 499	com/iknow/http/Response:getStatusCode	()I
    //   65: sipush 200
    //   68: if_icmpeq +11 -> 79
    //   71: ldc 54
    //   73: ldc_w 501
    //   76: invokestatic 506	com/iknow/util/Loger:e	(Ljava/lang/String;Ljava/lang/String;)V
    //   79: return
    //   80: astore 23
    //   82: aload 23
    //   84: astore 20
    //   86: new 123	HttpException
    //   89: dup
    //   90: aload 20
    //   92: invokevirtual 212	org/json/JSONException:getMessage	()Ljava/lang/String;
    //   95: invokespecial 213	HttpException:<init>	(Ljava/lang/String;)V
    //   98: athrow
    //   99: aload_1
    //   100: getstatic 509	com/iknow/OnlineAction:Delete	Lcom/iknow/OnlineAction;
    //   103: if_acmpne -53 -> 50
    //   106: new 204	org/json/JSONObject
    //   109: dup
    //   110: invokespecial 311	org/json/JSONObject:<init>	()V
    //   113: astore 4
    //   115: new 301	org/json/JSONArray
    //   118: dup
    //   119: invokespecial 302	org/json/JSONArray:<init>	()V
    //   122: astore 5
    //   124: aload_2
    //   125: invokeinterface 155 1 0
    //   130: astore 8
    //   132: aconst_null
    //   133: astore 9
    //   135: aload 8
    //   137: invokeinterface 161 1 0
    //   142: ifne +35 -> 177
    //   145: aload 4
    //   147: ldc_w 362
    //   150: aload 5
    //   152: invokevirtual 330	org/json/JSONObject:put	(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
    //   155: pop
    //   156: aload 4
    //   158: ldc_w 476
    //   161: ldc_w 513
    //   164: invokevirtual 330	org/json/JSONObject:put	(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
    //   167: pop
    //   168: aload 4
    //   170: invokevirtual 439	org/json/JSONObject:toString	()Ljava/lang/String;
    //   173: astore_3
    //   174: goto -124 -> 50
    //   177: aload 8
    //   179: invokeinterface 167 1 0
    //   184: checkcast 310	com/iknow/data/Word
    //   187: astore 12
    //   189: new 204	org/json/JSONObject
    //   192: dup
    //   193: invokespecial 311	org/json/JSONObject:<init>	()V
    //   196: astore 13
    //   198: aload 13
    //   200: ldc_w 362
    //   203: aload 12
    //   205: invokevirtual 355	com/iknow/data/Word:getKey	()Ljava/lang/String;
    //   208: invokevirtual 330	org/json/JSONObject:put	(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
    //   211: pop
    //   212: aload 5
    //   214: aload 13
    //   216: invokevirtual 307	org/json/JSONArray:put	(Ljava/lang/Object;)Lorg/json/JSONArray;
    //   219: pop
    //   220: aload 13
    //   222: astore 9
    //   224: goto -89 -> 135
    //   227: astore 6
    //   229: aload 6
    //   231: astore 7
    //   233: new 123	HttpException
    //   236: dup
    //   237: aload 7
    //   239: invokevirtual 212	org/json/JSONException:getMessage	()Ljava/lang/String;
    //   242: invokespecial 213	HttpException:<init>	(Ljava/lang/String;)V
    //   245: athrow
    //   246: astore 10
    //   248: aload 10
    //   250: astore 7
    //   252: aload 9
    //   254: pop
    //   255: goto -22 -> 233
    //   258: astore 19
    //   260: aload 19
    //   262: astore 20
    //   264: goto -178 -> 86
    //
    // Exception table:
    //   from	to	target	type
    //   9	18	80	org/json/JSONException
    //   124	132	227	org/json/JSONException
    //   198	220	227	org/json/JSONException
    //   135	168	246	org/json/JSONException
    //   177	198	246	org/json/JSONException
    //   18	44	258	org/json/JSONException
  }

  public String downloadFile(String paramString)
    throws HttpException
  {
    String str2;
    String str1 = IKnow.mCacheSystem.getFilePath(paramString);
    if (str1 != null)
      str2 = str1;
    while (true)
    {
      while (true)
      {
        return str2;
        InputStream localInputStream = get(paramString, null, false).asStream();
        if (IKnow.mCacheSystem.saveFile(paramString, localInputStream) != 0)
          break;
        str2 = IKnow.mCacheSystem.getFilePath(paramString);
      }
      str2 = null;
    }
  }

  public void feedback(String paramString1, String paramString2)
    throws HttpException
  {
    HashMap localHashMap = new HashMap();
    localHashMap.put("email", paramString1);
    localHashMap.put("value", paramString2);
    post("http://www.imiknow.com/iks/c/feedback.do", "json", new JSONObject(localHashMap).toString(), false);
  }

  public String fillPath(String paramString)
  {
    String str;
    if (paramString.indexOf("http://") == 0)
      str = paramString;
    while (true)
    {
      return str;
      str = "http://www.imiknow.com/iks/c" + paramString;
    }
  }

  protected Response get(String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, boolean paramBoolean)
    throws HttpException
  {
    ArrayList localArrayList = new ArrayList();
    localArrayList.add(new BasicNameValuePair(paramString2, HttpClient.encode(paramString3)));
    localArrayList.add(new BasicNameValuePair(paramString4, HttpClient.encode(paramString5)));
    return get(paramString1, localArrayList, paramBoolean);
  }

  protected Response get(String paramString, ArrayList<BasicNameValuePair> paramArrayList, boolean paramBoolean)
    throws HttpException
  {
    return this.http.get(paramString, paramArrayList, paramBoolean);
  }

  public Response get(String paramString, boolean paramBoolean)
    throws HttpException
  {
    return get(paramString, null, paramBoolean);
  }

  public List<Comment> getComments(String paramString, int paramInt1, int paramInt2)
    throws HttpException
  {
    HashMap localHashMap = new HashMap();
    localHashMap.put("cid", paramString);
    localHashMap.put("offset", String.valueOf(paramInt1));
    localHashMap.put("length", String.valueOf(paramInt2));
    JSONObject localJSONObject = new JSONObject(localHashMap);
    try
    {
      JSONArray localJSONArray = post("http://www.imiknow.com/iks/c/comment_list.do?", "json", localJSONObject.toString(), false).asJSONArray();
      ArrayList localArrayList = new ArrayList(localJSONArray.length());
      int i = 0;
      if (i >= localJSONArray.length())
        return localArrayList;
      localArrayList.add(new Comment(localJSONArray.getJSONObject(i)));
      ++i;
    }
    catch (HttpException localHttpException)
    {
      throw localHttpException;
    }
    catch (JSONException localJSONException)
    {
      throw new HttpException(localJSONException.getMessage());
    }
  }

  public List<QingboResponse> getFavoriteQingbos(String paramString, int paramInt1, int paramInt2)
    throws HttpException
  {
    HashMap localHashMap = new HashMap();
    localHashMap.put("user", paramString);
    JSONObject localJSONObject = new JSONObject(localHashMap);
    try
    {
      List localList = QingboResponse.QingboResponses(post("http://www.imiknow.com/iks/c/favorite_list.do", "json", localJSONObject.toString(), false));
      return localList;
    }
    catch (HttpException localHttpException)
    {
      throw localHttpException;
    }
  }

  public List<Word> getFavoriteWord(String paramString, int paramInt1, int paramInt2)
    throws HttpException
  {
    JSONObject localJSONObject = new JSONObject(new HashMap());
    try
    {
      localJSONObject.put("user", paramString);
    }
    catch (JSONException localJSONException)
    {
      try
      {
        JSONArray localJSONArray = post("http://www.imiknow.com/iks/c/word_list.do", "json", localJSONObject.toString(), false).asJSONArray();
        List localList = new Word().getWords(localJSONArray);
        return localList;
        localJSONException = localJSONException;
        localJSONException.printStackTrace();
      }
      catch (HttpException localHttpException)
      {
        throw localHttpException;
      }
    }
  }

  public String getQingBo(String paramString)
    throws HttpException
  {
    Object[] arrayOfObject = new Object[1];
    arrayOfObject[0] = paramString;
    String str1 = String.format("{\"cid\":\"%s\"}", arrayOfObject);
    try
    {
      String str2 = post("http://www.imiknow.com/iks/c/content.do", "json", str1, false).asString();
      return str2;
    }
    catch (HttpException localHttpException)
    {
      throw localHttpException;
    }
  }

  public String getQingBoLocal(String paramString)
    throws HttpException
  {
    Object localObject;
    Object[] arrayOfObject1 = new Object[1];
    arrayOfObject1[0] = paramString;
    String str1 = String.format("{\"cid\":\"%s\"}", arrayOfObject1);
    try
    {
      Object[] arrayOfObject2 = new Object[2];
      arrayOfObject2[0] = "http://www.imiknow.com/iks/c";
      arrayOfObject2[1] = str1;
      String str2 = String.format("%s/content.do?json=%s", arrayOfObject2);
      String str3 = IKnow.mCacheSystem.readFile(str2);
      if (StringUtil.isEmpty(str3))
      {
        localObject = null;
      }
      else
      {
        Response localResponse = new Response();
        localResponse.setResponseAsString(str3);
        String str4 = localResponse.asString();
        localObject = str4;
      }
    }
    catch (HttpException localHttpException)
    {
      throw localHttpException;
    }
    return localObject;
  }

  public List<QingBo> getQingboList(int paramInt1, int paramInt2)
    throws HttpException
  {
    HashMap localHashMap = new HashMap();
    localHashMap.put("offset", String.valueOf(paramInt1));
    localHashMap.put("length", String.valueOf(paramInt2));
    JSONObject localJSONObject = new JSONObject(localHashMap);
    try
    {
      List localList = QingBo.QingboResponses(post("http://www.imiknow.com/iks/c/content_list.do", "json", localJSONObject.toString(), false));
      return localList;
    }
    catch (HttpException localHttpException)
    {
      throw localHttpException;
    }
  }

  public List<QingBo> getQingboListByFollow(String paramString, int paramInt1, int paramInt2)
    throws HttpException
  {
    HashMap localHashMap = new HashMap();
    if (paramString != null)
      localHashMap.put("user_id", paramString);
    localHashMap.put("offset", String.valueOf(paramInt1));
    localHashMap.put("length", String.valueOf(paramInt2));
    JSONObject localJSONObject = new JSONObject(localHashMap);
    try
    {
      List localList = QingBo.QingboResponses(post("http://www.imiknow.com/iks/c/content_list.do", "json", localJSONObject.toString(), false));
      return localList;
    }
    catch (HttpException localHttpException)
    {
      throw localHttpException;
    }
  }

  public List<QingBo> getQingboListByFollowLocal(String paramString, int paramInt1, int paramInt2)
    throws HttpException
  {
    HashMap localHashMap = new HashMap();
    if (paramString != null)
      localHashMap.put("user_id", paramString);
    localHashMap.put("offset", String.valueOf(paramInt1));
    localHashMap.put("length", String.valueOf(paramInt2));
    JSONObject localJSONObject = new JSONObject(localHashMap);
    try
    {
      List localList = parseListByLocalResponse("http://www.imiknow.com/iks/c/content_list.do?json=" + localJSONObject.toString());
      return localList;
    }
    catch (HttpException localHttpException)
    {
      throw localHttpException;
    }
  }

  public List<QingBo> getQingboListByRosterID(String paramString, int paramInt1, int paramInt2)
    throws HttpException
  {
    HashMap localHashMap = new HashMap();
    JSONArray localJSONArray = createTags(paramString);
    localHashMap.put("offset", String.valueOf(paramInt1));
    localHashMap.put("length", String.valueOf(paramInt2));
    JSONObject localJSONObject = new JSONObject(localHashMap);
    try
    {
      localJSONObject.put("create_user", localJSONArray);
      List localList = QingBo.QingboResponses(post("http://www.imiknow.com/iks/c/content_list.do", "json", localJSONObject.toString(), false));
      return localList;
    }
    catch (HttpException localHttpException)
    {
      throw localHttpException;
    }
    catch (JSONException localJSONException)
    {
      throw new HttpException(localJSONException.getMessage());
    }
  }

  public List<QingBo> getQingboListByRosterIDLocal(String paramString, int paramInt1, int paramInt2)
    throws HttpException
  {
    Object localObject;
    if (paramString == null)
    {
      localObject = null;
      return localObject;
    }
    HashMap localHashMap = new HashMap();
    JSONArray localJSONArray = createTags(paramString);
    localHashMap.put("offset", String.valueOf(paramInt1));
    localHashMap.put("length", String.valueOf(paramInt2));
    JSONObject localJSONObject = new JSONObject(localHashMap);
    try
    {
      localJSONObject.put("create_user", localJSONArray);
      List localList = parseListByLocalResponse("http://www.imiknow.com/iks/c/content_list.do?json=" + localJSONObject.toString());
      localObject = localList;
    }
    catch (HttpException localHttpException)
    {
      throw localHttpException;
    }
    catch (JSONException localJSONException)
    {
      throw new HttpException(localJSONException.getMessage());
    }
  }

  public List<QingBo> getQingboListByTag(String paramString, int paramInt1, int paramInt2)
    throws HttpException
  {
    HashMap localHashMap = new HashMap();
    localHashMap.put("offset", String.valueOf(paramInt1));
    localHashMap.put("length", String.valueOf(paramInt2));
    JSONObject localJSONObject = new JSONObject(localHashMap);
    try
    {
      localJSONObject.put("tags", createTags(paramString));
      List localList = QingBo.QingboResponses(post("http://www.imiknow.com/iks/c/content_list.do", "json", localJSONObject.toString(), false));
      return localList;
    }
    catch (HttpException localHttpException)
    {
      throw localHttpException;
    }
    catch (JSONException localJSONException)
    {
      throw new HttpException(localJSONException.getMessage());
    }
  }

  public List<QingBo> getQingboListByTagLocal(String paramString, int paramInt1, int paramInt2)
    throws HttpException
  {
    HashMap localHashMap = new HashMap();
    localHashMap.put("offset", String.valueOf(paramInt1));
    localHashMap.put("length", String.valueOf(paramInt2));
    JSONObject localJSONObject = new JSONObject(localHashMap);
    try
    {
      localJSONObject.put("tags", createTags(paramString));
      Object[] arrayOfObject = new Object[2];
      arrayOfObject[0] = "http://www.imiknow.com/iks/c";
      arrayOfObject[1] = localJSONObject.toString();
      List localList = parseListByLocalResponse(String.format("%s/content_list.do?json=%s", arrayOfObject));
      return localList;
    }
    catch (HttpException localHttpException)
    {
      throw localHttpException;
    }
    catch (JSONException localJSONException)
    {
      throw new HttpException(localJSONException.getMessage());
    }
  }

  public List<QingBo> getQingboListLocal(int paramInt1, int paramInt2)
    throws HttpException
  {
    HashMap localHashMap = new HashMap();
    localHashMap.put("offset", String.valueOf(paramInt1));
    localHashMap.put("length", String.valueOf(paramInt2));
    JSONObject localJSONObject = new JSONObject(localHashMap);
    Object[] arrayOfObject = new Object[2];
    arrayOfObject[0] = "http://www.imiknow.com/iks/c";
    arrayOfObject[1] = localJSONObject.toString();
    return parseListByLocalResponse(String.format("%s/content_list.do?json=%s", arrayOfObject));
  }

  public String getSession()
  {
    return this.mSessionID;
  }

  public String getShareQingboUrl(String paramString)
  {
    Object[] arrayOfObject = new Object[1];
    arrayOfObject[0] = paramString;
    return String.format("http://www.imiknow.com/details.aspx?id=%s", arrayOfObject);
  }

  public List<SubscribeTag> getSubscribeTags()
    throws HttpException
  {
    List localList;
    try
    {
      localList = TagResponse.getSubscribeTag(get("http://www.imiknow.com/iks/c/taggroup_list.do", false));
      return localList;
    }
    catch (JSONException localJSONException)
    {
      throw new HttpException(localJSONException.getMessage());
    }
    catch (HttpException localHttpException)
    {
      throw localHttpException;
    }
  }

  public List<String> getrecommendedUsers()
    throws HttpException, JSONException
  {
    JSONArray localJSONArray = get("http://www.imiknow.com/iks/c/recommend_account.json", false).asJSONArray();
    ArrayList localArrayList = new ArrayList(localJSONArray.length());
    int i = 0;
    while (true)
    {
      if (i >= localJSONArray.length())
        return localArrayList;
      localArrayList.add(localJSONArray.getString(i) + "@" + "imiknow.com");
      ++i;
    }
  }

  public UserResponse login(String paramString1, String paramString2)
    throws HttpException
  {
    Object[] arrayOfObject = new Object[2];
    arrayOfObject[0] = paramString1;
    arrayOfObject[1] = paramString2;
    String str = String.format("{\"username\":\"%s\", \"password\":\"%s\"}", arrayOfObject);
    try
    {
      HttpClient localHttpClient = this.http;
      BasicNameValuePair[] arrayOfBasicNameValuePair = new BasicNameValuePair[1];
      arrayOfBasicNameValuePair[0] = new BasicNameValuePair("json", str);
      UserResponse localUserResponse = new UserResponse(localHttpClient.post("http://www.imiknow.com/iks/c/login.do", createParams(arrayOfBasicNameValuePair)));
      return localUserResponse;
    }
    catch (HttpException localHttpException)
    {
      throw localHttpException;
    }
  }

  public void logout()
  {
    IKnow.mIKnowDataBase.deleteUser();
    IKnow.mIKnowDataBase.deleteAllFriend();
    IKnow.mIKnowDataBase.deleteAllSession();
    IKnow.mIKnowDataBase.deleteAllMessage();
    IKnow.mIKnowDataBase.deleteAllSubscribeTag();
    IKnow.mSystemConfig.setString("com.weibo.android.accesstoken", "");
    IKnow.mSystemConfig.setString("com.weibo.android.token.secret", "");
    IKnow.mSystemConfig.setString("account_username", "");
    IKnow.mSystemConfig.setString("account_password", "");
  }

  public Response post(String paramString1, String paramString2, String paramString3, boolean paramBoolean)
    throws HttpException
  {
    ArrayList localArrayList = new ArrayList();
    localArrayList.add(new BasicNameValuePair(paramString2, paramString3));
    return this.http.post(paramString1, localArrayList, paramBoolean);
  }

  public List<QingBo> queryQingboListByKeyword(String paramString, int paramInt1, int paramInt2)
    throws HttpException
  {
    HashMap localHashMap = new HashMap();
    localHashMap.put("offset", String.valueOf(paramInt1));
    localHashMap.put("length", String.valueOf(paramInt2));
    localHashMap.put("nameLike", paramString);
    JSONObject localJSONObject = new JSONObject(localHashMap);
    try
    {
      List localList = QingBo.QingboResponses(post("http://www.imiknow.com/iks/c/content_list.do", "json", localJSONObject.toString(), false));
      return localList;
    }
    catch (HttpException localHttpException)
    {
      throw localHttpException;
    }
  }

  public JSONObject requestSession()
    throws HttpException
  {
    JSONObject localJSONObject;
    try
    {
      localJSONObject = get("http://www.imiknow.com/iks/c/index.do", false).asJSONObject();
      return localJSONObject;
    }
    catch (HttpException localHttpException)
    {
      throw localHttpException;
    }
  }

  public void setSessionID(String paramString)
  {
    this.mSessionID = paramString;
  }

  public int writeQingBo(QingBo paramQingBo, String paramString1, String paramString2)
    throws HttpException
  {
    int i = 0;
    if (paramString2 != null);
    try
    {
      ArrayList localArrayList = new ArrayList();
      localArrayList.add(new BasicNameValuePair("file", "file"));
      HttpClient localHttpClient = this.http;
      File localFile = new File(paramString2);
      JSONObject localJSONObject = localHttpClient.httpRequest("http://www.imiknow.com/iks/u/upload.do", localArrayList, localFile, true, "POST").asJSONObject();
      String str1 = ".." + localJSONObject.getString("path");
      String str2 = null;
      if (paramQingBo.getType() == QingboType.image)
      {
        Bitmap localBitmap = IKnow.mProfileImageCacheManager.getImageManager().getFromLocal(paramString2);
        Object[] arrayOfObject3 = new Object[3];
        arrayOfObject3[0] = Integer.valueOf(localBitmap.getWidth());
        arrayOfObject3[1] = Integer.valueOf(localBitmap.getHeight());
        arrayOfObject3[2] = str1;
        str2 = String.format("<img width='%s' height='%d' src='%s'/>", arrayOfObject3);
        localBitmap.recycle();
        paramQingBo.setThumbnailUrl(str1);
      }
      Object[] arrayOfObject1 = new Object[2];
      arrayOfObject1[0] = str2;
      arrayOfObject1[1] = paramString1;
      String str3 = createQingBoJSONString(paramQingBo, String.format("<html><body><p>%s</p><p>%s</p></body></html>", arrayOfObject1), localJSONObject.getString("path"));
      Object[] arrayOfObject2 = new Object[1];
      arrayOfObject2[0] = "http://www.imiknow.com/iks/u";
      boolean bool = post(String.format("%s/add_content.do", arrayOfObject2), "json", str3, true).asString().equalsIgnoreCase("1");
      if (bool)
        i = 1;
      return i;
    }
    catch (HttpException localHttpException)
    {
      throw localHttpException;
    }
    catch (JSONException localJSONException)
    {
      throw new HttpException(localJSONException.getMessage());
    }
  }

  public String writeTextQingBo(QingBo paramQingBo, String paramString)
    throws HttpException
  {
    Object[] arrayOfObject1 = new Object[1];
    arrayOfObject1[0] = paramString;
    String str1 = createQingBoJSONString(paramQingBo, String.format("<html><body><p>%s</p></body></html>", arrayOfObject1), null);
    try
    {
      Object[] arrayOfObject2 = new Object[1];
      arrayOfObject2[0] = "http://www.imiknow.com/iks/u";
      String str2 = post(String.format("%s/add_content.do", arrayOfObject2), "json", str1, true).asString();
      return str2;
    }
    catch (HttpException localHttpException)
    {
      throw localHttpException;
    }
  }
}